# PowerShell脚本：发布到Gitee
# 设置编码
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8

Write-Host "========================================" -ForegroundColor Green
Write-Host "发布代码到Gitee" -ForegroundColor Green
Write-Host "========================================" -ForegroundColor Green

# 设置Git配置
Write-Host "1. 配置Git编码..." -ForegroundColor Yellow
git config --global core.quotepath false
git config --global i18n.commitencoding utf-8
git config --global i18n.logoutputencoding utf-8

# 检查状态
Write-Host "`n2. 检查Git状态..." -ForegroundColor Yellow
git status

# 添加文件
Write-Host "`n3. 添加所有更改..." -ForegroundColor Yellow
git add .

# 提交更改
Write-Host "`n4. 提交更改..." -ForegroundColor Yellow
git commit -m "feat: implement log file preview functionality

- Add LogView component for log file selection and preview
- Add /logs/files and /logs/content API endpoints
- Support UTF-8 encoding and line count control
- Improve error handling and responsive design"

# 配置远程仓库
Write-Host "`n5. 配置Gitee远程仓库..." -ForegroundColor Yellow
Write-Host "请先修改脚本中的Gitee用户名和仓库名！" -ForegroundColor Red

# 请替换为您的实际Gitee信息
$GITEE_USERNAME = "your-username"  # 请修改为您的Gitee用户名
$REPO_NAME = "lemon-process"
$GITEE_URL = "https://gitee.com/$GITEE_USERNAME/$REPO_NAME.git"

# 移除现有的gitee远程仓库
git remote remove gitee 2>$null

# 添加Gitee远程仓库
git remote add gitee $GITEE_URL

# 推送代码
Write-Host "`n6. 推送到Gitee..." -ForegroundColor Yellow
Write-Host "使用令牌进行身份验证..." -ForegroundColor Cyan

# 设置认证信息
$env:GIT_ASKPASS = "echo"
$env:GIT_USERNAME = $GITEE_USERNAME
$env:GIT_PASSWORD = "855ef5e5209b4aa07f2fc571494b6255"

# 推送代码
git push -u gitee master

Write-Host "`n========================================" -ForegroundColor Green
Write-Host "发布完成！" -ForegroundColor Green
Write-Host "========================================" -ForegroundColor Green
Write-Host "请访问 https://gitee.com/$GITEE_USERNAME/$REPO_NAME 查看代码" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Green

Read-Host "按任意键继续..."
